package com.industrial.loweff.controller;

import com.industrial.common.core.web.domain.AjaxResult;
import com.industrial.loweff.domain.CityLevelCdCount;
import com.industrial.loweff.domain.JcQueryParam;
import com.industrial.loweff.service.IBigPingService;
import com.industrial.loweff.service.ILowEfficiencyEnterprisesAnalysisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;
import java.util.List;
import java.util.Map;

/**
 * 低效能企业大屏
 * @author sangguangcan
 */
@RestController
@RequestMapping("/bigping")
public class BigPingController {

    @Autowired
    private IBigPingService bigPingService;

    @Autowired
    private ILowEfficiencyEnterprisesAnalysisService lowEfficiencyEnterprisesAnalysisService;

    /**
     * 查询近五年的数据
     * @return
     */
    @GetMapping("/queryFiveData")
    public AjaxResult queryFiveData(JcQueryParam params){
        params.setEndYear(String.valueOf( Integer.valueOf(params.getYears())- 5));
        params.setProvince("370000");
        Map<String, Object> resultMap = lowEfficiencyEnterprisesAnalysisService.queryFiveData(params);
        return AjaxResult.success(resultMap);
    }

    /**
     * 查询地图上的数据
     * @return
     */
    @GetMapping("/queryMapData")
    public AjaxResult queryMapData(JcQueryParam params){
        params.setProvince("370000");
        List<CityLevelCdCount> cityLevelCdCounts = lowEfficiencyEnterprisesAnalysisService.queryMapData(params);
        return AjaxResult.success(cityLevelCdCounts);
    }

    /**
     * 查询雷达图数据
     * @return
     */
    @GetMapping("/queryLdImg")
    public AjaxResult queryLdImg(JcQueryParam params){
        params.setProvince("370000");
        Map<String, Object> resultMap = lowEfficiencyEnterprisesAnalysisService.queryLoweIndexFbInfo(params);
        return AjaxResult.success(resultMap);
    }

    /**
     * 低效能企业城市分布
     * @param params
     * @return
     */
    @GetMapping("/queryLowerCompanyCityLoc")
    public AjaxResult queryLowerCompanyCityLoc(JcQueryParam params){
        params.setProvince("370000");
        Map<String, Object> resultMap = lowEfficiencyEnterprisesAnalysisService.queryLoweCity(params);
        return AjaxResult.success(resultMap);
    }

    @GetMapping("/queryLowerIndustry")
    public AjaxResult queryLowerIndustry(JcQueryParam params){
        params.setProvince("370000");
        Map<String, Object> resultMap = lowEfficiencyEnterprisesAnalysisService.queryLoweIndustry(params);
        return AjaxResult.success(resultMap);
    }

    /**
     * 查询低效能指标
     * @param params
     * @return
     */
    @GetMapping("/queryLowerIndex")
    public  AjaxResult queryLowerIndex(JcQueryParam params){
        params.setProvince("370000");
        String years = params.getYears();
        Integer yearsInt = Integer.valueOf(years);
        Integer endYear = yearsInt - 5;
        params.setEndYear(String.valueOf(endYear));
        Map<String,Object> result = lowEfficiencyEnterprisesAnalysisService.queryIndex(params);
        return AjaxResult.success(result);
    }

    /**
     * 查询用地面积占比
     * @param params
     * @return
     */
    @GetMapping("/queryLowYdmmzb")
    public AjaxResult queryLowYdmmzb(JcQueryParam params){
        params.setProvince("370000");
        List<Map<String, Object>> maps = lowEfficiencyEnterprisesAnalysisService.queryLowYdmmzb(params);
        return AjaxResult.success(maps);
    }

    /**
     * 低效能企业研发强度
     * @param params
     * @return
     */
    @GetMapping("/queryLowCompanyYfQd")
    public AjaxResult queryLowCompanyYfQd(JcQueryParam params){
        params.setProvince("370000");
        Map<String, Object> result = lowEfficiencyEnterprisesAnalysisService.queryLowCompanyYfQd(params);
        return AjaxResult.success(result);
    }
}
